package br.com.foxinline.servico;

import br.com.foxinline.generico.ServicoGenerico;
import br.com.foxinline.modelo.Requerimento;
import br.com.foxinline.modelo.TramiteRequerimento;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author elyjunior
 */
@Stateless
public class TramiteRequerimentoServico extends ServicoGenerico<TramiteRequerimento> {
    
    public TramiteRequerimentoServico(){
        super(TramiteRequerimento.class);
    }
          
    public List<TramiteRequerimento> lstTramiteRequerimento(Requerimento requerimento) {
        String sql = "SELECT t FROM Requerimento r JOIN r.tramites t WHERE r.id  = :id ORDER BY r.id";
        Query query = getEntityManager().createQuery(sql);
        query.setParameter("id", requerimento.getId());
        return (List<TramiteRequerimento>) query.getResultList();
    }
}
